﻿using System;
using bGallery.Core.Common;

namespace bGallery.Controls
{
	/// <summary>
	/// UserControl for logged user displaying
	/// </summary>
	public partial class LoggedUser : UserControl
	{
		private bool logged = false;

		/// <summary>
		/// Handles page load events
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Page_Load(object sender, EventArgs e)
		{
			if (SignedInUser.Id > 0)
			{
				logged = true;
				lblLoginInformation.Text = SignedInUser.Username;
			}

			pnlLogged.Visible = logged;
			pnlNotLogged.Visible = !logged;
		}

		/// <summary>
		/// Signes out currently sidned in user
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Logout(object sender, EventArgs e)
		{
			SetResult("Logout");
		}
	}
}